package com.totcy.atom.view.activity;

import android.support.v4.view.MenuItemCompat;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;

import com.totcy.atom.R;
import com.totcy.atom.view.fragment.WeatherFragment;
import com.totcy.baselibrary.utils.ToastUtil;

public class WeatherActivity extends BaseFullActivity implements SearchView.OnQueryTextListener {
    private WeatherFragment weatherFragment;

    @Override
    public String getTitleName() {
        return "";
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_weather;
    }

    @Override
    public void initView() {
        weatherFragment = (WeatherFragment) getSupportFragmentManager().findFragmentById(R.id.fragmentWeather);

        //设置右上角菜单
        getToolbarTitleLayout().inflateMenu(R.menu.menu_weather_search);
        //找到searchView
        MenuItem searchItem = getToolbarTitleLayout().getMenu().findItem(R.id.weather_search);
        SearchView searchView = (SearchView) searchItem.getActionView();
        searchView.setOnQueryTextListener(this);
        searchView.setQueryHint(getString(R.string.input_city_name_to_search));
    }

    @Override
    public boolean onQueryTextSubmit(String s) {
        if (weatherFragment != null) {
            weatherFragment.onSearch(s);
        }
        return false;
    }

    @Override
    public boolean onQueryTextChange(String s) {
        return false;
    }
}
